package com.IClass;

import java.util.List;
import java.util.Map;

import com.IClass.App.R;
import com.IClass.iAskListAdapter.ListItemView;
import com.IClass.image.AsynImageLoader;

import android.content.Context;
import android.content.res.TypedArray;
import android.view.View;
import android.view.ViewGroup;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.BaseAdapter;
import android.widget.Gallery;
import android.widget.ImageView;
import android.widget.TextView;

public class IGalleryImageAdapter extends BaseAdapter {

    private Context mContext;
    private AsynImageLoader mImageAsynLoader;
    private List<String> imageurlslist;
    private int selectItem;
	public IGalleryImageAdapter(Context context,List<String> list)
	{
		mContext = context;
        // 获得Gallery组件的属性
		mImageAsynLoader = new AsynImageLoader();
		imageurlslist = list;
	}
	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return imageurlslist.size(); 
	}

	@Override
	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return position;
		
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) 
	{
		// TODO Auto-generated method stub

		String imageurl = (String) this.imageurlslist.get(position);// 存放图片所对应的url

		ImageView imageview = null;
		if (convertView == null) 
		{

			imageview = new ImageView(mContext);
			convertView = imageview;
			imageview.setTag(imageurl);
		} 
		else 
		{
			imageview = (ImageView) convertView.getTag();
		}

		imageview.setScaleType(ImageView.ScaleType.FIT_XY);

		mImageAsynLoader.loadBitmap(imageview, ImageUtil.getBitmapById(convertView.getContext(), R.drawable.icon_3_n));
		
//		if(selectItem==position)
//		{  
//			 Animation animation = AnimationUtils.loadAnimation(mContext, R.anim.imageviw_zoomout);    //实现动画效果  
//			 imageview.setLayoutParams(new Gallery.LayoutParams(105,120));  
//			 imageview.startAnimation(animation);  //选中时，这是设置的比较大  
//		}
//		else
//		{
//			imageview.setLayoutParams(new Gallery.LayoutParams(75,90));
//		}
		
		///////////////////////////////
		
		
		return convertView;
	}
	 public void setSelectItem(int selectItem) 
	 {  
         
	        if (this.selectItem != selectItem) 
	        {                  
	        	this.selectItem = selectItem;  
	        	notifyDataSetChanged();                 
	        }  
	 }  
}
